package zoran.wang.calculate.impl;

import zoran.wang.calculate.Calculation;
import zoran.wang.utils.LogUtils;

/**
 * description：
 *
 * @author wangzhuo
 * @date 2022/3/19 19:07
 * @Email zoranwang@yeah.net
 */
public class FoolishCalculator implements Calculation {
    @Override
    public int add(int a, int b) {
        LogUtils.logBefore("加法", a, b);
        int result = 0;
        try {
            result = a + b;
            LogUtils.logAfterReturning("加法", result);
        } catch (Exception e) {
            LogUtils.logAfterThrowing("加法", e);
            throw new RuntimeException(e);
        }
        return result;
    }

    @Override
    public int div(int a, int b) {
        LogUtils.logBefore("除法", a, b);
        int result = 0;
        try {
            result = a / b;
            LogUtils.logAfterReturning("除法", result);
        } catch (Exception e) {
            LogUtils.logAfterThrowing("除法", e);
            throw new RuntimeException(e);
        }
        return result;
    }
}
